<template>
  <el-form ref="form" :model="sort" label-width="80px">
    <el-form-item label="导航名">
      <el-input v-model="sort.sortName"></el-input>
    </el-form-item>
    <el-form-item label="描述">
      <el-input v-model="sort.sortDescribe" type="textarea"></el-input>
    </el-form-item>
    <el-form-item>
      <el-button type="primary" @click="addSubmit">立即创建</el-button>
      <el-button>取消</el-button>
    </el-form-item>
  </el-form>
</template>

<script>

import { addSortNav } from '@/api/sort'

export default {
  name: 'AddPrimaryNav',
  data() {
    return {
      sort: {
        sortName: '',
        sortDescribe: ''
      }
    }
  },
  methods: {
    addSubmit() {
      this.$confirm('是否添加?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        addSortNav(this.sort).then(res => {
          this.$message.success(res.message)
          this.$router.push({
            path: '/Navigation',
            query: { user: JSON.stringify(this.user) }
          })
        })
      }).catch(() => {
        this.$message({
          type: 'info',
          message: '已取消修改'
        })
      })
    }
  }
}
</script>

<style scoped>

</style>
